class Page extends React.Component{
    constructor(props){ //构造函数
        super(props);
        this.state = {
            test:{},
            arr:[]
        }
    }
    getData(){ //请求数据函数
        fetch(`/bagevent-web/showloginlog`,{
            method: 'GET',
            headers:{
                'Content-Type':'application/json;charset=UTF-8'
            }
        }).then(res => res.json())
            .then((data)=>{
                this.setState({
                    test:data
                },function () {
                    let com = this.state.test.map((item,index)=>{
                        return <p key={index}>登录时间：{new Date(item.loginTime).toLocaleString()}登录IP：{item.loginIp}</p>
                    })
                    this.setState({
                        arr:com
                    })
                })
            })
    }

    componentWillMount(){
        this.getData();
    }


    render(){
            return(
                <div>
                    {this.state.arr}
                </div>
            );
    }
}
ReactDOM.render(
    <Page />,
    document.getElementById('loginlog')
);